home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / packet / p_aa4re / mbb35src / 8250tmr.asm < prev    next >
Encoding:
Assembly Source File  |  1988-09-25  |  4.6 KB  |  92 lines

  1. ;==========================================================================;
  2. ; 8250 Timer service                                                       ;
  3. ;   This code also used by the QUADRAM QUADPORT board and 4 async port card;
  4. ;                                                                          ;
  5. ;   Copyright 1986, 1987, 1988 by H. Roy Engehausen.  All rights reserved. ;
  6. ;   This software may be freely distributed and used, but it may not       ;
  7. ;   under any circumstances be sold by anyone other than the author.       ;
  8. ;   It may be distributed by a commercial company as long as it is         ;
  9. ;   for no cost.                                                           ;
  10. ;                                                                          ;
  11. ;   Permission is explicity granted to use this code as a model for        ;
  12. ;   other programs requiring interupt driven serial I/O as long as they    ;
  13. ;   carry this copyright notice.                                           ;
  14. ;==========================================================================;
  15.  
  16. ;--------------------------------------------------------------------------;
  17. ; If not time then don't do it.                                            ;
  18. ;--------------------------------------------------------------------------;
  19.  
  20.         CMP     timer_counter,0     ; Timer wrapped?
  21.         JNZ     tmr_8250_done       ;      No... We are done
  22.  
  23. ;--------------------------------------------------------------------------;
  24. ; Transmit buffering?  If not, nothing to do                               ;
  25. ;--------------------------------------------------------------------------;
  26.  
  27.         TEST    options[SI],opt_trbuf ; Transmit buffering turned on?
  28.         JZ      tmr_8250_done       ;      No... We are done
  29.  
  30. ;--------------------------------------------------------------------------;
  31. ; Transmitter on?   If so just turn the flag off                           ;
  32. ;--------------------------------------------------------------------------;
  33.  
  34.         TEST    flags[SI],flags_xmt_on ; Transmitter on in the last slice?
  35.         JNZ     tmr_8250_tx_on      ;      Yes... Just turn off flag
  36.  
  37. ;--------------------------------------------------------------------------;
  38. ; Anything in transmit buffer?  If not, we are done                        ;
  39. ;--------------------------------------------------------------------------;
  40.  
  41.         MOV     AX,buffer_t_in[SI]  ; Get buffer input pointer
  42.         CMP     AX,buffer_t_out[SI] ; See where the out pointer is
  43.         JE      tmr_8250_done       ; If they are equal then we have no
  44.  
  45. ;--------------------------------------------------------------------------;
  46. ; Oh Oh...  The thing might be stuck...  Unstuck it....                    ;
  47. ;--------------------------------------------------------------------------;
  48.  
  49.         CLI                         ; In case someone tries to multiprocess
  50.  
  51. ;       MOV     DL,hiv[SI]          ; Get the hardware interrupt vector address
  52. ;       MOV     tmr_8250_int,DL     ; Put it where we need it
  53. ;
  54. ;       JMP     $+2                 ; Clean out the prefetch stack
  55. ;       INT     00H                 ; Interrupt!
  56. ;       ORG     $-1
  57. ;mr_8250_int DB  ?                  ; Place to put interrupt number
  58. ;
  59.  
  60. ;--------------------------------------------------------------------------;
  61. ; Cause an interrupt by setting the IIR to zero and then back to what it   ;
  62. ; was.  This will cause an THR empty interrupt.                            ;
  63. ;--------------------------------------------------------------------------;
  64.  
  65.         MOV     DX,baseaddr[SI]     ; Get base address for chip
  66.         ADD     DX,ier_8250         ; Address IER
  67.         IN      AL,DX               ; Get it
  68.         MOV     AH,AL               ; Save it
  69.         SUB     AL,AL               ; Now send zero
  70.         OUT     DX,AL               ;      to IER
  71.         MOV     AL,AH               ; Now restore IER
  72.         JMP     $+2                 ; Delay
  73.         OUT     DX,AL               ;
  74.  
  75.         STI                         ;
  76.  
  77.         JMP     SHORT tmr_8250_done
  78.  
  79. ;--------------------------------------------------------------------------;
  80. ; Clear transmit flag                                                      ;
  81. ;--------------------------------------------------------------------------;
  82.  
  83. tmr_8250_tx_on:
  84.  
  85.         AND     flags[SI],0FFH-flags_xmt_on ; Turn off transmitter flag
  86.  
  87. ;--------------------------------------------------------------------------;
  88. ; All timer functions for 8250 are done                                    ;
  89. ;--------------------------------------------------------------------------;
  90.  
  91. tmr_8250_done:
  92.